import axios from "axios";
import { message } from "ant-design-vue";

export const request = axios.create({
  baseURL: "http://localhost:9999",
  timeout: 5000,
});

request.interceptors.response.use(
  (response) => {
    if (response.data.code === 0) {
      message.error(response.data.message);
    } else {
      return response.data;
    }
  },
  (error) => {
    return Promise.reject(error);
  }
);
export default request;
